<?php
namespace app\logic;

use think\facade\Db;

class Index extends Base
{
    /**
     * 获取首页展示数据
     * @return array
     */
    public function indexData()
    {
        $soft_count = (new \app\model\Software())->field("id")->count();
        $ver_count = (new \app\model\Version())->field("id")->count();
        $file_count = (new \app\model\Upload())->field("id")->count();
        $sys_info = [
            '操作系统' => PHP_OS,
            '剩余空间' => function_exists('disk_free_space') ? round((disk_free_space('.')/(1024*1024)),2).'M' : "未知",
            '服务器地址' =>$_SERVER['HTTP_HOST'],
            '运行环境' =>  request()->server('SERVER_SOFTWARE'),
            'PHP 版本' => PHP_VERSION,
            'MySQL 版本' => function_exists('mysql_get_server_info') ? mysql_get_server_info() : Db::query('SELECT VERSION() as mysql_version')[0]['mysql_version'],
            'ThinkPHP 版本' => app()->version(),
            '上传文件限制' => ini_get('upload_max_filesize'),
            '执行超时时间' => ini_get('max_execution_time').'秒',
        ];

        return [
            'softCount' => $soft_count,
            'verCount'  => $ver_count,
            'fileCount' => $file_count,
            'sysInfo'   => $sys_info
        ];
    }

}